package Demo1;

class Shape {

    public void draw() {
        System.out.println("画图形");
    }
}

class Circular extends Shape {
    @Override
    public void draw() {
        System.out.println("圆形");
    }
}

class Rectangle extends Shape {
    @Override
    public void draw() {
        System.out.println("矩形");
    }
}
class Triangle extends Shape {
    @Override
    public void draw() {
        System.out.println("三角形");
    }
}
public class Test {
    public static void drawShapes(Shape shape) {
        shape.draw();
    }
    public static void main(String[] args) {
        //多态的优缺点
       Shape circular = new Circular();
       Shape rectangle  = new Rectangle();
       Shape triangle = new Triangle();
        Shape[] shapes = {circular,rectangle,circular,rectangle,triangle};
        //循环打印
        for (Shape shape:shapes) {
            shape.draw();
        }
//        Circular circular = new Circular();//圆
//        Triangle triangle = new Triangle();//三角形
//        Rectangle rectangle = new Rectangle();//矩形//
//        drawShapes(circular);
//        drawShapes(triangle);
//        drawShapes(rectangle);
    }
}
